home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / lib / gcc-lib / ppc-amigaos / 2.95.1 / sys-include / sys / wait.h < prev   
C/C++ Source or Header  |  2000-03-13  |  6KB  |  164 lines

  1. #ifndef _WAIT_H_
  2. #define _WAIT_H_
  3.  
  4. /*
  5.  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
  6.  * All rights reserved.
  7.  *
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  * 2. Redistributions in binary form must reproduce the above copyright
  14.  *    notice, this list of conditions and the following disclaimer in the
  15.  *    documentation and/or other materials provided with the distribution.
  16.  * 3. All advertising materials mentioning features or use of this software
  17.  *    must display the following acknowledgement:
  18.  *    This product includes software developed by the University of
  19.  *    California, Berkeley and its contributors.
  20.  * 4. Neither the name of the University nor the names of its contributors
  21.  *    may be used to endorse or promote products derived from this software
  22.  *    without specific prior written permission.
  23.  *
  24.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34.  * SUCH DAMAGE.
  35.  *
  36.  *    @(#)wait.h    7.17 (Berkeley) 6/19/91
  37.  */
  38.  
  39. /*
  40.  * This file holds definitions relevent to the wait4 system call
  41.  * and the alternate interfaces that use it (wait, wait3, waitpid).
  42.  */
  43.  
  44. /*
  45.  * Macros to test the exit status returned by wait
  46.  * and extract the relevant values.
  47.  */
  48. #ifdef _POSIX_SOURCE
  49. #define    _W_INT(i)    (i)
  50. #else
  51. #define    _W_INT(w)    (*(int *)&(w))    /* convert union wait to int */
  52. #define    WCOREFLAG    0200
  53. #endif
  54.  
  55. #define    _WSTATUS(x)    (_W_INT(x) & 0177)
  56. #define    _WSTOPPED    0177        /* _WSTATUS if process is stopped */
  57. #define WIFSTOPPED(x)    (_WSTATUS(x) == _WSTOPPED)
  58. #define WSTOPSIG(x)    (_W_INT(x) >> 8)
  59. #define WIFSIGNALED(x)    (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
  60. #define WTERMSIG(x)    (_WSTATUS(x))
  61. #define WIFEXITED(x)    (_WSTATUS(x) == 0)
  62. #define WEXITSTATUS(x)    (_W_INT(x) >> 8)
  63. #ifndef _POSIX_SOURCE
  64. #define WCOREDUMP(x)    (_W_INT(x) & WCOREFLAG)
  65.  
  66. #define    W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
  67. #define    W_STOPCODE(sig)        ((sig) << 8 | _WSTOPPED)
  68. #endif
  69.  
  70. /*
  71.  * Option bits for the second argument of wait4.  WNOHANG causes the
  72.  * wait to not hang if there are no stopped or terminated processes, rather
  73.  * returning an error indication in this case (pid==0).  WUNTRACED
  74.  * indicates that the caller should receive status about untraced children
  75.  * which stop due to signals.  If children are stopped and a wait without
  76.  * this option is done, it is as though they were still running... nothing
  77.  * about them is returned.
  78.  */
  79. #define WNOHANG        1    /* dont hang in wait */
  80. #define WUNTRACED    2    /* tell about stopped, untraced children */
  81.  
  82. #ifndef _POSIX_SOURCE
  83. /* POSIX extensions and 4.2/4.3 compatability: */
  84.  
  85. /*
  86.  * Tokens for special values of the "pid" parameter to wait4.
  87.  */
  88. #define    WAIT_ANY    (-1)    /* any process */
  89. #define    WAIT_MYPGRP    0    /* any process in my process group */
  90.  
  91. #ifndef BYTE_ORDER
  92. #include <machine/endian.h>
  93. #endif
  94.  
  95. /*
  96.  * Deprecated:
  97.  * Structure of the information in the status word returned by wait4.
  98.  * If w_stopval==WSTOPPED, then the second structure describes
  99.  * the information returned, else the first.
  100.  */
  101. union wait {
  102.     int    w_status;        /* used in syscall */
  103.     /*
  104.      * Terminated process status.
  105.      */
  106.     struct {
  107. #if BYTE_ORDER == LITTLE_ENDIAN 
  108.         unsigned int    w_Termsig:7,    /* termination signal */
  109.                 w_Coredump:1,    /* core dump indicator */
  110.                 w_Retcode:8,    /* exit code if w_termsig==0 */
  111.                 w_Filler:16;    /* upper bits filler */
  112. #endif
  113. #if BYTE_ORDER == BIG_ENDIAN 
  114.         unsigned int    w_Filler:16,    /* upper bits filler */
  115.                 w_Retcode:8,    /* exit code if w_termsig==0 */
  116.                 w_Coredump:1,    /* core dump indicator */
  117.                 w_Termsig:7;    /* termination signal */
  118. #endif
  119.     } w_T;
  120.     /*
  121.      * Stopped process status.  Returned
  122.      * only for traced children unless requested
  123.      * with the WUNTRACED option bit.
  124.      */
  125.     struct {
  126. #if BYTE_ORDER == LITTLE_ENDIAN 
  127.         unsigned int    w_Stopval:8,    /* == W_STOPPED if stopped */
  128.                 w_Stopsig:8,    /* signal that stopped us */
  129.                 w_Filler:16;    /* upper bits filler */
  130. #endif
  131. #if BYTE_ORDER == BIG_ENDIAN 
  132.         unsigned int    w_Filler:16,    /* upper bits filler */
  133.                 w_Stopsig:8,    /* signal that stopped us */
  134.                 w_Stopval:8;    /* == W_STOPPED if stopped */
  135. #endif
  136.     } w_S;
  137. };
  138. #define    w_termsig    w_T.w_Termsig
  139. #define w_coredump    w_T.w_Coredump
  140. #define w_retcode    w_T.w_Retcode
  141. #define w_stopval    w_S.w_Stopval
  142. #define w_stopsig    w_S.w_Stopsig
  143.  
  144. #define    WSTOPPED    _WSTOPPED
  145. #endif /* _POSIX_SOURCE */
  146.  
  147. #ifndef _KERNEL
  148. #include <sys/types.h>
  149. #include <sys/cdefs.h>
  150.  
  151. __BEGIN_DECLS
  152. struct rusage;    /* forward declaration */
  153.  
  154. pid_t    wait __P((int *));
  155. pid_t    waitpid __P((pid_t, int *, int));
  156. #ifndef _POSIX_SOURCE
  157. pid_t    wait3 __P((int *, int, struct rusage *));
  158. pid_t    wait4 __P((pid_t, int *, int, struct rusage *));
  159. #endif
  160. __END_DECLS
  161. #endif
  162.  
  163. #endif
  164.